﻿@model Sykj.Entity.Permissions
@{
    ViewData["Title"] = "编辑权限";
    Layout = "~/Areas/Manager/Views/Shared/_Layout.cshtml";
}
<div class="layui-bg">
    <form class="layui-form" style="padding: 20px 30px 0 0;">
        <input type="hidden" asp-for="PermissionId">
        <div class="layui-form-item">
            <label class="layui-form-label">所属父级</label>
            <div class="layui-input-block">
                <select asp-for="ParentId" asp-items="@ViewBag.PermissionsTreeList" lay-search></select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">权限名称</label>
            <div class="layui-input-block">
                <input type="text" asp-for="Title" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限描述</label>
            <div class="layui-input-block">
                <input type="text" asp-for="Description" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">url</label>
            <div class="layui-input-block">
                <input type="text" asp-for="Url" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">图标</label>
            <div class="layui-input-block">
                <input type="text" asp-for="Icon" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" asp-for="Sort" lay-verify="number" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-block">
                <input type="checkbox" asp-for="IsEnable" lay-skin="switch" lay-filter="isenable">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">权限类型</label>
            <div class="layui-input-block">
                <input type="radio" name="Type" value="1" @(Model.Type == 1 ? "checked" : "") title="模块">
                <input type="radio" name="Type" value="2" @(Model.Type == 2 ? "checked" : "") title="菜单">
                <input type="radio" name="Type" value="3" @(Model.Type == 3 ? "checked" : "") title="按钮">

            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="edit" id="submit" type="button">提交</button>
                <button id="close" type="button" class="layui-btn layui-btn-primary">关闭</button>
            </div>
        </div>
    </form>
</div>
    @section scriptsfeet
        {
        <script type="text/javascript">
    layui.config({
        base: '/layuiadmin/' //自定义模块路径
    }).use(['form', 'sykjwh'], function () {
        var $ = layui.$,
            form = layui.form,
            sykjwh = layui.sykjwh;

        $("#close").click(function () {
            sykjwh.close();
        });

        form.on('submit(edit)', function (obj) {
            //保存
            obj.field.IsEnable = $("#IsEnable").val();
            sykjwh.save('@Url.Action("edit", "permissions", new { area = Constant.AREAMANAGER })', obj.field);
        });

        //监听checkbox
        form.on('switch(isenable)', function (data) {
            this.value = data.elem.checked;
        });
    });
        </script>
    }
